//
//  CYDatabase.h
//  CreditAddressBook
//
//  Created by Lee on 15/10/15.
//  Copyright © 2015年 Lee. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "LEDBConfig.h"
@class FMDatabaseQueue;
@class CYCollection;
@class CYCallHistory;

@interface CYDatabase : LEDBConfig

/**
 *  单例模式，子类重写
 */
+ (instancetype)sharedDatabase;

//- (FMDatabaseQueue *)DBQueue;

#pragma mark - 收藏
/**
 *  保存一条记录
 */
- (BOOL)addCollection:(CYCollection *)collection;

/**
 *  删除一条记录
 */
- (BOOL)deleteCollectionWithId:(NSString *)collectionId;

/**
 *  根据电话号码删除一条记录
 *
 *  @param phone 电话号码
 *
 *  @return
 */
- (BOOL)deleteCollectionWithPhoneNum:(NSString *)phone;

/**
 *  根据recordId查询记录
 */
- (NSArray *)collectionWithRecordId:(NSString *)recordId;

/**
 *  获取收藏记录
 */
- (NSArray *)collections;

/**
 *  根据电话号码查询收藏记录
 */
- (NSArray *)collectionsWithPhone:(NSString *)phone;

/**
 *  根据电话号码和名称删除收藏记录
 *  persons CYCloudPerson
 */
- (BOOL)deleteCollectionsWithPersons:(NSArray *)persons;

/**
 *  根据电话号码和名称查询收藏记录
 */
- (NSArray *)collectionsWithPhone:(NSString *)phone andName:(NSString *)name;
#pragma mark - 通话记录
/**
 *  保存一条通话记录
 *
 *  @param history
 */
- (void)addCallHistory:(CYCallHistory *)history;

/**
 *  保存多条通话记录
 *
 *  @param historys
 */
- (void)addCallHistorys:(NSArray *)historys;

/**
 *  更新N条记录
 *
 *  @param historys
 */
- (void)updateCallHistorys:(NSArray *)historys;

/**
 *  更新一条记录
 *
 *  @param history
 */
- (void)updateCallHistory:(CYCallHistory *)history;

/**
 *  更新通话记录
 *
 *  @param callHistory
 */
- (BOOL)updateDuration:(CYCallHistory *)callHistory;

/**
 *  根据条件读取通话记录
 *
 *
 *  @return
 */
- (NSArray *)callHistorysWithParam:(NSDictionary *)param;
@end
